//
//  PopoverViewController.swift
//  WeiBoOfSwift
//
//  Created by aven wu on 20/04/2018.
//  Copyright © 2018 GML. All rights reserved.
//

import UIKit
import SnapKit

class PopoverViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    static let cellReuseable:String = "cellReuseable"
    
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        bgImgView.frame = view.bounds
        tab.frame = CGRect(x: 20, y: 20, width: view.bounds.size.width-40, height: view.bounds.size.height-40)
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        view.addSubview(bgImgView)
        view.addSubview(tab)
        
    }
    //MARK: tableView datasource
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return 20
    }
    // MARK: tableView delegate
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: PopoverViewController.cellReuseable, for: indexPath)
        return cell
    }
    
    
    private lazy  var bgImgView:UIImageView = {
       let bg = UIImageView()
        bg.frame = CGRect(x: 0, y: 0, width: view.bounds.size.width, height: view.bounds.size.height)
        bg.image = UIImage(named:"popover_background")
        return bg
    }()
    
    private lazy var tab:UITableView = {
    
       let tab = UITableView(frame: CGRect.zero, style: UITableViewStyle.plain)
        tab.frame = CGRect.init(x: 20, y: 20, width: view.bounds.size.width-40, height: view.bounds.size.height-40)
        tab.register(UITableViewCell.self, forCellReuseIdentifier: PopoverViewController.cellReuseable)
        tab.delegate = self
        tab.dataSource  = self
        return tab
    }()


}
